Skip to content

Conversation

@clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Dec 19, 2018

Presumably, this will require an RFC to properly stabilise, but this seems simple enough to warrant opening a PR. I doubt the API would be substantially different from the one I've provided, as it's very simple.

Basically, there are a few things in the standard library that have a try_clone method, and it seems very reasonable to add a TryClone trait as an analogue to TryFrom and TryInto. I've personally run into a few cases where it'd be useful to have a trait like this, although again, it's up to others on whether this is useful.

A few unanswered questions:

  • Would #[derive(TryClone)] even make sense? What would the error type be?
  • Should there be a try_clone_from? What would the behaviour be if the clone fails?
  • Once this trait is added, should the inherent methods be soft-deprecated?

@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 19, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Dec 26, 2018

☔ The latest upstream changes (presumably #57108) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril
Copy link
Contributor

Centril commented Jan 25, 2019

Triage... reassigning randomly to someone else on libs... r? @SimonSapin

@rust-highfive rust-highfive assigned SimonSapin and unassigned Kimundi Jan 25, 2019
@SimonSapin
Copy link
Contributor

I don’t really see the point of this trait. Would any code ever use it as a bound on a generic type parameter?

I think this needs more motivation than analogy and “seems reasonable”.

@Dylan-DPC-zz
Copy link

ping from triage @clarcharr closing this based on the last comment. Thanks for contributing. If you have a better reason and motivation behind this you can ask it to be reopened or create a new pull request.

@Dylan-DPC-zz Dylan-DPC-zz added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 11, 2019
@clarfonthey clarfonthey deleted the try_clone branch January 29, 2022 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants